home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 417_01 / libftp / FtpGetHost.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  1001 b   |  45 lines

  1. /*
  2.               Library for ftpd clients.(libftp)
  3.             Copyright by Oleg Orel
  4.              All rights reserved.
  5.             
  6. This  library is desined  for  free,  non-commercial  software  creation. 
  7. It is changeable and can be improved. The author would greatly appreciate 
  8. any  advises, new  components  and  patches  of  the  existing  programs.
  9. Commercial  usage is  also  possible  with  participation of it's author.
  10.  
  11.  
  12.  
  13. */
  14.  
  15. #include "FtpLibrary.h"
  16.  
  17.  
  18.  
  19. struct hostent *FtpGetHost(char *host)
  20. {
  21.  
  22.   static struct in_addr addr;
  23.   static struct hostent _host;
  24.   static char *point[2];
  25.   static char *alias[1];
  26.  
  27.   bzero(&_host,sizeof _host);
  28.   if ( (addr.s_addr=inet_addr(host)) != -1 )
  29.     {
  30.       _host.h_addr_list = point;
  31.       _host.h_addr_list[0] = (char *) &addr;
  32.       _host.h_addr_list[1] = (char *) 0;
  33.       alias[0]=NULL;
  34.       _host.h_aliases=alias;
  35.       _host.h_name=host;
  36.       _host.h_length=sizeof(unsigned long);
  37.       _host.h_addrtype=AF_INET;
  38.       return &_host;
  39.     }
  40.   
  41.   return gethostbyname(host);
  42. }
  43.  
  44.  
  45.